package com.company.servicename.util;

import java.util.function.Function;

/**
 * @author fangsong.zhang
 * @date 2019/9/27 15:31
 * Copyright zfs
 * 类说明: 多线程实现
 */
public class ThreadObj<T> implements Runnable {

    private Function function;
    private T obj;

    public ThreadObj(Function function, T obj) {
        this.function = function;
        this.obj = obj;
    }

    /**
     * When an object implementing interface <code>Runnable</code> is used
     * to create a thread, starting the thread causes the object's
     * <code>run</code> method to be called in that separately executing
     * thread.
     * <p>
     * The general contract of the method <code>run</code> is that it may
     * take any action whatsoever.
     *
     * @see Thread#run()
     */
    @Override
    public void run() {
        this.function.apply(obj);
    }
}
